package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.query.CommentQueryObject;
import cn.wolfcode.trip.base.query.DailyQueryObject;
import cn.wolfcode.trip.base.service.ICommentService;
import cn.wolfcode.trip.base.service.IDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/dailys")
public class DailyController {
    @Autowired
    private IDailyService dailyervice ;
    @Autowired
    private ICommentService commentService ;


    /*
    获取这篇日报的所有评论
    参数：
    资源：/travels/{travelId}/comments
    动作：GET
     */
    @GetMapping("/{dailyId}/comments")
    public Object getComments(CommentQueryObject qo){
        qo.setOrderBy("c.creatTime desc");
        return commentService.queryForLits(qo);
    }


    @GetMapping
    public Object getDailys(DailyQueryObject qo){
        //查询到全部的数据
        return dailyervice.query(qo);
    }


    @GetMapping("/{id}")
    public Object getDetail(@PathVariable Long id){

        return dailyervice.getBigNews(id);
    }
}
